jjzjj

javascript - Expressjs 不会破坏 session

全部标签

ruby-on-rails - 带有 redirect_to 的 Flash 通知在 rails 中被破坏

我已更新到Rails2.3.10、Rack1.2.1,现在我的所有即时消息都没有显示。我发现在重定向期间,通知是这样传递的redirect_to(@user,:notice=>"Sorrytherewasanerror")在我看来闪存哈希是空的!map:ActionController::Flash::FlashHash{}但是您可以在Controller中看到该消息。是什么原因?session{:home_zip=>"94108",:session_id=>"xxx",:flash=>{:notice=>"Sorrytherewasanerror"},:user_credential

ruby-on-rails - Facebook Canvas 应用程序不保存 session

我制作了一个测试facebook应用程序只是为了玩玩,我正在使用session来存储身份验证。我正在使用omniauth。当我从http://fbbtest.heroku.com/登录时然后刷新页面,session仍然保存,它说我已经登录。当我从Canvas上尝试时http://apps.facebook.com/herokutestapp/它让我登录,重定向回来并说我已登录但是当我手动刷新它然后说我没有登录。我必须对rails3中的session做一些特别的事情以便它也可以在FacebookCanvas?这是我目前在我的Controller和View中拥有的内容defindexend

ruby-on-rails - rails heroku - 如何安装需要 'npm install ...' 的 javascript 依赖项

我正在将我的Rails应用程序部署到heroku。我想使用一些javascript库,它们希望我们像这样安装npm依赖项:npminstallabc因此,在本地我可以安装npm和执行“npminstallabc”。不确定如何在heroku中与我的Rails应用程序一起使用。 最佳答案 使用Heroku的多重构建方法:UsingMultipleBuildpacksforanApp通过先安装NodeJS,再安装Ruby,Heroku将在Ruby中发生任何事情之前安装您的Node依赖项。herokubuildpacks:setheroku

ruby - apt Recipe 不会安装在我的 Recipe 中

我正在尝试使用Vagrant创建我的第一个ChefRecipe,但在第一步就遇到了问题。我的Recipe的第一行是:include_recipe"apt"但是当我尝试vagrantprovision时,出现以下错误:==>default:[2014-09-21T07:15:42+00:00]WARN:MissingCookbookDependency:==>default:Recipe`apt`isnotintherun_list,andcookbook'apt'==>default:isnotadependencyofanycookbookintherun_list.Toloadth

ruby - Rails 3 不会用 rvm 安装 sqlite3-ruby gem?

我正在试用rvm,并用它安装了ruby​​1.9.2和rails3。我需要重新安装sqlite3-rubygem(因为rvm为不同版本的ruby​​将所有gem分开)。问题是,当我尝试时,我得到:geminstallsqlite3-ruby/home/jenny/.rvm/rubies/ruby-1.9.2-p0/bin/gem:4:warning:Insecureworldwritabledir/home/jenny/.rvm/gems/ruby-1.9.2-p0/bininPATH,mode040777Buildingnativeextensions.Thiscouldtakeaw

ruby - 为什么包含此模块不会覆盖动态生成的方法?

我正在尝试通过包含一个模块来覆盖动态生成的方法。在下面的示例中,Ripple关联将rows=方法添加到Table。我想调用那个方法,但之后还要做一些额外的事情。我创建了一个模块来覆盖该方法,认为该模块的row=将能够调用super以使用现有方法。classTable#Rippleassociation-createsrows=methodmany:rows,:class_name=>Table::Row#Hackyfirstattempttousethedynamically-created#methodandalsodoadditionalstuff-Iwouldactually#m

ruby-on-rails - 如何在与 rails 的 session 中设置多维数组

我正在尝试做这样的事情:session[:continent][:filter]=params[:filter]但它不起作用,我收到了这个错误:Youhaveanilobjectwhenyoudidn'texpectit!YoumighthaveexpectedaninstanceofArray.Theerroroccurredwhileevaluatingnil.[]= 最佳答案 您需要先将session[:continent]初始化为Hash。试试这个:session[:continent]||={}session[:conti

ruby - 为什么 Logger 输出到 STDOUT 不会重定向到文件?

这个脚本被命名为o.rb:@logger=Logger.new(STDOUT)@logger.info"start_time:#{start_time}"当我使用./o.rb运行它时,控制台上的输出是正确的。但是,当我尝试./o.rb>log.txt2>&1时,日志文件是空的!为什么会这样?我在使用简单的puts函数时遇到了同样的问题。更新这将重现此问题:require'logger'logger=Logger.new(STDOUT)loopdologger.info"Thisisatesthaha"sleep(1)end当我使用./foo.rb运行它时,它会正确写入控制台输出。当我运

ruby-on-rails - 在 Sinatra 中使用 Rack::Session::Pool

我正在探索Sinatra,我想使用session,但我不想将它们存储在Cookie中,我发现Rack::Session::Pool效果很好。现在我希望session在一定持续时间后过期,但我不明白如何实例化Rack::Session::Pool并且他们在Sinatra中使用它。有什么线索吗? 最佳答案 Sinatra非常强大,TheWickedFlea的技巧没有奏效,但这个确实奏效了:useRack::Session::Pool,:domain=>'example.com',:expire_after=>60*60*24*365谢谢

ruby-on-rails - 即使安装了 libv8,Gem therubyracer 也不会安装

我已经使用以下命令在Windows上安装了libv8gem:geminstalllibv8----with-system-v8然后当我尝试安装therubyracer时,它给了我很长的错误消息:Installingtherubyracer0.12.2withnativeextensionsGem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension.currentdirectory:D:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/therubyracer-0.12.2/ext/v8D:/Ruby21-